<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:dgh="clr-namespace:DentalGUIHelper;assembly=DentalConfig">
    <ResourceDictionary.MergedDictionaries>
        <!-- This is required because we use StaticResoruce -->
        <ResourceDictionary Source="../Brushes/Colors.xaml" />
    </ResourceDictionary.MergedDictionaries>
    <Style x:Key="ColorSliderButtonStyle" TargetType="{x:Type RepeatButton}">
        <Setter Property="SnapsToDevicePixels" Value="true"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Border Background="Transparent"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="HorizontalColorSliderThumbStyle" TargetType="{x:Type Thumb}">
        <Setter Property="SnapsToDevicePixels" Value="true"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Height" Value="1"/>
        <Setter Property="Width" Value="12"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
					<Canvas>
						<Canvas.RenderTransform>
							<TranslateTransform X="6" />
						</Canvas.RenderTransform>
						<Polygon Points="-5,-12 0,-4 5,-12" Fill="{TemplateBinding Foreground}" >
						</Polygon>						
						<Polygon Points="-5,11 5,11 0,3" Fill="{TemplateBinding Foreground}" >
						</Polygon>
						<Rectangle Canvas.Left="-6" Canvas.Top="-12" Width="12" Height="24" Fill="Black" Opacity="0" />		
					</Canvas>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Foreground" Value="{StaticResource BackgroundHighlightedBrush}"/>
                            <Setter Property="BorderBrush" Value="{StaticResource BorderHighlightedBrush}"/>
                        </Trigger>
                        <Trigger Property="IsDragging" Value="True">
                            <Setter Property="Foreground" Value="{StaticResource BackgroundSelectedBrush}"/>
                            <Setter Property="BorderBrush" Value="{StaticResource BorderSelectedBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
	
    <Style x:Key="VerticalColorSliderThumbStyle" TargetType="{x:Type Thumb}">
        <Setter Property="SnapsToDevicePixels" Value="true"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Height" Value="12"/>
        <Setter Property="Width" Value="1"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
					<Canvas >
						<Canvas.RenderTransform>
							<TranslateTransform Y="6" />
						</Canvas.RenderTransform>
						<Polygon Points="-5,-12 0,-4 5,-12" Fill="{TemplateBinding Foreground}" >
							<Polygon.RenderTransform>
								<RotateTransform Angle="90" />
							</Polygon.RenderTransform>
						</Polygon>						
						<Polygon Points="-5,11 5,11 0,3" Fill="{TemplateBinding Foreground}" >
							<Polygon.RenderTransform>
								<RotateTransform Angle="90" />
							</Polygon.RenderTransform>
						</Polygon>
						<Rectangle Canvas.Left="-12" Canvas.Top="-6" Width="24" Height="12" Fill="Black" Opacity="0" />		
					</Canvas>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Foreground" Value="{StaticResource BackgroundHighlightedBrush}"/>
                            <Setter Property="BorderBrush" Value="{StaticResource BorderHighlightedBrush}"/>
                        </Trigger>
                        <Trigger Property="IsDragging" Value="True">
                            <Setter Property="Foreground" Value="{StaticResource BackgroundSelectedBrush}"/>
                            <Setter Property="BorderBrush" Value="{StaticResource BorderSelectedBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
	
    <ControlTemplate x:Key="HorizontalColorSlider" TargetType="{x:Type dgh:ColorSlider}">
        <Grid Height="Auto" MinHeight="{TemplateBinding Slider.MinHeight}">
            <Border Name="TrackBackground" Height="12" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" Margin="5 0 5 0">
				<Grid>
					<Rectangle >
						<Rectangle.Fill>
							<DrawingBrush Viewport="0,0,10,10"  ViewportUnits="Absolute" TileMode="Tile">
								<DrawingBrush.Drawing>
									<DrawingGroup>
										<GeometryDrawing Brush="White">
											<GeometryDrawing.Geometry>
												<RectangleGeometry Rect="0,0,10,10" />
											</GeometryDrawing.Geometry>
										</GeometryDrawing>
										<GeometryDrawing Brush="Gray">
											<GeometryDrawing.Geometry>
												<GeometryGroup>
													<RectangleGeometry Rect="0,0,5,5" />
													<RectangleGeometry Rect="5,5,5,5" />
												</GeometryGroup>
											</GeometryDrawing.Geometry>
										</GeometryDrawing>
									</DrawingGroup>
								</DrawingBrush.Drawing>
							</DrawingBrush>
						</Rectangle.Fill>
					</Rectangle>
					<Rectangle x:Name="rect" Fill="{TemplateBinding Background}" />
				</Grid>
            </Border>
            <Track Name="PART_Track">
                <Track.DecreaseRepeatButton>
                    <RepeatButton Command="Slider.DecreaseLarge" Style="{StaticResource ColorSliderButtonStyle}"/>
                </Track.DecreaseRepeatButton>
                <Track.Thumb>
                    <Thumb Style="{StaticResource HorizontalColorSliderThumbStyle}" />
                </Track.Thumb>
                <Track.IncreaseRepeatButton>
                    <RepeatButton Command="Slider.IncreaseLarge" Style="{StaticResource ColorSliderButtonStyle}"/>
                </Track.IncreaseRepeatButton>
            </Track>
        </Grid>
    </ControlTemplate>

    <ControlTemplate x:Key="VerticalColorSlider" TargetType="{x:Type dgh:ColorSlider}">
        <Grid MinWidth="{TemplateBinding Slider.MinWidth}" Width="Auto">
            <Border Name="TrackBackground" Width="12" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" Margin="0 5 0 5">
				<Grid>
					<Rectangle >
						<Rectangle.Fill>
							<DrawingBrush Viewport="0,0,10,10"  ViewportUnits="Absolute" TileMode="Tile">
								<DrawingBrush.Drawing>
									<DrawingGroup>
										<GeometryDrawing Brush="White">
											<GeometryDrawing.Geometry>
												<RectangleGeometry Rect="0,0,10,10" />
											</GeometryDrawing.Geometry>
										</GeometryDrawing>
										<GeometryDrawing Brush="Gray">
											<GeometryDrawing.Geometry>
												<GeometryGroup>
													<RectangleGeometry Rect="0,0,5,5" />
													<RectangleGeometry Rect="5,5,5,5" />
												</GeometryGroup>
											</GeometryDrawing.Geometry>
										</GeometryDrawing>
									</DrawingGroup>
								</DrawingBrush.Drawing>
							</DrawingBrush>
						</Rectangle.Fill>
					</Rectangle>
					<Rectangle x:Name="rect" Fill="{TemplateBinding Background}" />
				</Grid>
            </Border>
            <Track Name="PART_Track">
                <Track.DecreaseRepeatButton>
                    <RepeatButton Command="Slider.DecreaseLarge" Style="{StaticResource ColorSliderButtonStyle}"/>
                </Track.DecreaseRepeatButton>
                <Track.Thumb>
                    <Thumb Style="{StaticResource VerticalColorSliderThumbStyle}" />
                </Track.Thumb>
                <Track.IncreaseRepeatButton>
                    <RepeatButton Command="Slider.IncreaseLarge" Style="{StaticResource ColorSliderButtonStyle}"/>
                </Track.IncreaseRepeatButton>
            </Track>
        </Grid>
    </ControlTemplate>

    <Style TargetType="{x:Type dgh:ColorSlider}">
		<Setter Property="IsMoveToPointEnabled" Value="true"/>
        <Setter Property="SnapsToDevicePixels" Value="true"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Background" Value="{DynamicResource BrandBrush1}" />
        <Setter Property="Foreground" Value="{DynamicResource BrandBrush2}" />
        <Setter Property="BorderBrush" Value="#A6A6A6" />
        <Style.Triggers>
            <Trigger Property="Orientation" Value="Horizontal">
                <Setter Property="MinWidth" Value="104"/>
                <Setter Property="MinHeight" Value="21"/>
                <Setter Property="Template" Value="{StaticResource HorizontalColorSlider}"/>
            </Trigger>
            <Trigger Property="Orientation" Value="Vertical">
                <Setter Property="MinWidth" Value="21"/>
                <Setter Property="MinHeight" Value="104"/>
                <Setter Property="Template" Value="{StaticResource VerticalColorSlider}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Opacity" Value="0.6" />
            </Trigger>
        </Style.Triggers>
    </Style>
</ResourceDictionary>